package org.example.classloader;



import java.math.BigDecimal;
import java.util.ArrayList;

public class LoadTest {
    public static void main(String[] args) {
        for (int i = 0; i < 100000; i++) {
            System.out.println(getFib(i+1));
        }

    }

    private static double getSqrt(double target){
        //xn+1 = (xn + target / xn) /2
        double result = target == 0 ? 0 : -1;
        if (target > 0){
            double precision = 10e-10;
            double x1 = target ;
            double x2 = (x1 + target / x1) / 2;
            while ((x1 > x2 ? x1 - x2 : x2 - x1) > precision){
                x1 = x2;
                x2 = (x1 + target / x1) / 2;
            }
            BigDecimal var0 = new BigDecimal(String.valueOf(x2));
            result =  var0.setScale(4,BigDecimal.ROUND_HALF_UP).doubleValue();
        }
        return result;
    }

    private static String getFib(int n){
        if (n <= 2){
            return "1";
        }
        int pre = 1;
        int ppre = 1;
        int result = 0;
        for (int i = 3; i <=n; i++) {
            result = (pre + ppre) % 10000;
            ppre = pre;
            pre = result;
        }
        return String.format("%04d",result);
    }
}
